<?php

require_once(CORE_DIR.'components/phpmailer/class.phpmailer.php');
class phpmailerComponent extends PHPMailer {
	
	function __construct()
	{
		parent::__construct();
	}

	public function create($subject,$body,$email,$template=null)
	{
		if(!empty($subject) && !empty($body) && !empty($email)) {
			$this->isSMTP();
	        $this->Host = 'smtp.gmail.com'; 
	        $this->Port = 465; 
	        $this->SMTPAuth = true;    
	        $this->Username = 'izwebz.art@gmail.com';
	        $this->Password = 'vominhman';     
	        $this->SMTPSecure = 'ssl';   
	        $this->From = 'izwebz.art@gmail.com';
	        $this->FromName = 'izwebz.com'; 
	        $this->addAddress($email, '');
	        $this->isHTML(true);        
	        $this->Subject = $subject;
	        $this->Body    = !empty($template) ? $this->loadTemplate($body,$template) : $body;
	        $this->CharSet = "UTF-8";
	        $this->send();
		}
	}

	public function loadTemplate($body,$template)
	{
		return $this->$template($body);
	}

	/* Create template here */

}